<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <script th:src="@{/}+'js/tool.js'"></script>
    <style type="text/css">
        .layui-form .layui-form-item{
            width:90%;
        }
        .layui-input-inline{
            width:170px!important
        }
    </style>

</head>
<body style="margin-top: 100px">
<form class="layui-form" lay-filter="myform" id="myform">
    <input type="hidden" name="state" value="1">
    <input type="hidden" name="id" id="id" th:value="${id}">
    <div class="layui-form-item">
        <label class="layui-form-label">试卷名称</label>
        <div class="layui-input-inline">
            <input type="text" name="name" autocomplete="off" class="layui-input">
        </div>
        <label class="layui-form-label">中/英文</label>
        <div class="layui-input-inline">
            <select name="lg" id="lg"></select>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">学院/系</label>
        <div class="layui-input-inline">
            <select name="collegeId" id="collegeId"></select>
        </div>
        <label class="layui-form-label">考试专业</label>
        <div class="layui-input-inline">
            <select name="major" id="major"></select>
        </div>
        <label class="layui-form-label">考试科目</label>
        <div class="layui-input-inline">
            <select name="categoryId" id="categoryId"></select>
        </div>
    </div>
    <div class="layui-form-item">

        <label class="layui-form-label">学生类型</label>
        <div class="layui-input-inline">
            <select name="studentType" id="studentType"></select>
        </div>
        <label class="layui-form-label">试卷编号</label>
        <div class="layui-input-inline">
            <input type="text" id="code" name="code" placeholder="系统生成" readonly="readonly" autocomplete="off" class="layui-input" th:value="${id}">
        </div>
        <label class="layui-form-label">A/B/C卷</label>
        <div class="layui-input-inline">
            <select name="paperType" id="paperType"></select>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">考生年级</label>
        <div class="layui-input-inline">
            <select name="grade" id="grade"></select>
        </div>
        <label class="layui-form-label">考试学年</label>
        <div class="layui-input-inline">
            <select name="gradeYear" id="gradeYear"></select>
        </div>
        <label class="layui-form-label">考试学期</label>
        <div class="layui-input-inline">
            <select name="semester" id="semester"></select>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">考试阶段</label>
        <div class="layui-input-inline">
            <select name="testPhase" id="testPhase"></select>
        </div>
        <label class="layui-form-label">考试方式</label>
        <div class="layui-input-inline">
            <select name="testType" id="testType"></select>
        </div>
        <label class="layui-form-label">考试时长</label>
        <div class="layui-input-inline">
            <input type="number" name="howlong" autocomplete="off" class="layui-input">
        </div><div class="layui-form-mid">分钟</div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">单选题数</label>
        <div class="layui-input-inline">
            <input type="number" name="num1" autocomplete="off" class="layui-input">
        </div>
        <label class="layui-form-label">多选题数</label>
        <div class="layui-input-inline">
            <input type="number" name="num2" autocomplete="off" class="layui-input">
        </div>
        <label class="layui-form-label">判断题数</label>
        <div class="layui-input-inline">
            <input type="number" name="num3" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">简单题数</label>
        <div class="layui-input-inline">
            <input type="number" name="num4" autocomplete="off" class="layui-input">
        </div>
        <label class="layui-form-label">计算分析题数</label>
        <div class="layui-input-inline">
            <input type="number" name="num5" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">每道单选分</label>
        <div class="layui-input-inline">
            <input type="number" name="score1" autocomplete="off" class="layui-input">
        </div>
        <label class="layui-form-label">每道多选题分</label>
        <div class="layui-input-inline">
            <input type="number" name="score2" autocomplete="off" class="layui-input">
        </div>
        <label class="layui-form-label">每道判断分</label>
        <div class="layui-input-inline">
            <input type="number" name="score3" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">每道简单分</label>
        <div class="layui-input-inline">
            <input type="number" name="score4" autocomplete="off" class="layui-input">
        </div>
        <label class="layui-form-label">每道计算分析分</label>
        <div class="layui-input-inline">
            <input type="number" name="score5" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">登记人</label>
        <div class="layui-input-inline">
            <input type="text" name="createUserName" id="createUserName" th:value="${session.me.name}" readonly="readonly" class="layui-input">
            <input type="hidden" name="createUserId" id="createUserId" th:value="${session.me.id}">
        </div>
        <label class="layui-form-label">登记时间</label>
        <div class="layui-input-inline">
            <input type="text" name="createTime" id="createTime" th:value="${currentTime}" readonly="readonly" class="layui-input">
        </div>
    </div>
    <button id="submitBtn" class="layui-btn" style="display:none" lay-submit lay-filter="submitme">保存</button>
</form>

<script>
    var id = $("#id").val();
    layui.link('layuiadmin/plugins/layui_complete-master/autocomplete.css');
    layui.extend({
        autocomplete: '{/}layuiadmin/plugins/layui_complete-master/autocomplete'
    });

    layui.use(['form', 'table', 'laydate','autocomplete'], function(){
        var form = layui.form;
        createSelect("test-phase","testPhase",form,'','请选择');
        createSelect("paper-lg","lg",form,1,'请选择');
        createSelect("semester","semester",form,1,'请选择');
        createSelect("student-type","studentType",form,1,'请选择');
        createSelect("test-type","testType",form,1,'请选择');
        createSelect("paper-type","paperType",form,'','请选择');
        select('libCategory/getPageList?limit=40&page=1' , 'categoryId',form,'name','id')
        select('gradeYear/getPageList?limit=40&page=1' , 'gradeYear',form,'name','id')
        select('grade/getPageList?limit=40&page=1' , 'grade',form,'name','id')
        select('college/getPageList?limit=40&page=1' , 'collegeId',form,'name','id')
        select('major/getPageList?limit=30&page=1' , 'major',form,'name','id')
        form.on('submit(submitme)', function(data){
            var values = {};
            $(":input").each(function(i,v){
                if(v.name)
                    values[v.name] = v.value;
            })
            axios.post("paper/save",values).then(ret=>{
                if(ret.data.code==1){
                    layer.msg(ret.data.msg);
                }else{
                    var win = getTabWin();
                    win.loadGrid('main-table');
                    top.layer.alert("保存成功",{icon:1});
                    var index = top.layer.getFrameIndex(window.name);
                    top.layer.close(index);
                }
            })
            return false;
        });
        if(id){
            loadData()
        }
        function loadData(){
            var entity = getEntityInfo(id,"paper/getById");
            form.val("myform",entity);
            if(entity.state==2){
                $("input").attr("readOnly",true)
                $(":input").attr("disabled",true)
            }
        }

    })
</script>
</body>
</html>

</body>
</html>